package JAVA克隆;

/**
 * 项目名称：Demo01
 * 类 名 称：CloneEntitySenior
 * 类 描 述：TODO
 * 创建时间：2021/03/15 18:04
 * 创 建 人：XiaoCoder
 */
public class CloneEntitySenior implements Cloneable {

    private int num;

    private CloneEntity cloneEntity;


    public CloneEntity getCloneEntity() {
        return cloneEntity;
    }

    public void setCloneEntity(CloneEntity cloneEntity) {
        this.cloneEntity = cloneEntity;
    }

    public int getNum() {
        return num;
    }

    public void setNum(int num) {
        this.num = num;
    }

    @Override
    protected Object clone() throws CloneNotSupportedException {
        CloneEntitySenior entitySenior = null;
        try {
            entitySenior = (CloneEntitySenior) super.clone(); // 浅复制
        } catch (CloneNotSupportedException e) {
            e.printStackTrace();
        }
        entitySenior.cloneEntity = (CloneEntity) cloneEntity.clone(); // 深度复制
        return entitySenior;
    }
}
